CSharpTest.Net
EncodeBytes(Byte[],Int32,Int32) Method
See Also  Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Formatting Namespace > HexEncoding Class > EncodeBytes Method : EncodeBytes(Byte[],Int32,Int32) Method

input
start
length

Glossary Item Box

Transforms a sequence of characters from '0' - '9' and 'a' - 'f' in the binary values

Syntax

Visual Basic (Declaration) 
Public Overloads Shared Function EncodeBytes( _
   ByVal input() As Byte, _
   ByVal start As Integer, _
   ByVal length As Integer _
) As String
C# 
public static string EncodeBytes( 
   byte[] input,
   int start,
   int length
)

Parameters

input
start
length

Example

Library/Library.Test/TestHexEncoding.cs

C#Copy Code
const string hex = "0102030405060708090a0b0c0d0e0f10";
byte[] bin = new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 };

Assert.AreEqual(hex.Substring(4, 10), HexEncoding.EncodeBytes(bin, 2, 5));
Assert.AreEqual(0, BinaryComparer.Compare(new byte[] { 3, 4, 5, 6 }, HexEncoding.DecodeBytes(hex, 4, 8)));
VB.NETCopy Code
Const  hex As String = "0102030405060708090a0b0c0d0e0f10"
Dim bin As Byte() = New Byte() {1, 2, 3, 4, 5, 6, _
    7, 8, 9, 10, 11, 12, _
    13, 14, 15, 16}

Assert.AreEqual(hex.Substring(4, 10), HexEncoding.EncodeBytes(bin, 2, 5))
Assert.AreEqual(0, BinaryComparer.Compare(New Byte() {3, 4, 5, 6}, HexEncoding.DecodeBytes(hex, 4, 8)))

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Generated with Document! X 2011 by Innovasys